﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using CF.Member.DAL.Member;

namespace CaifenWeb.UtilityCls
{
    public class FormAuthenticationService
    {
        /// <summary>
        /// 登录后Identity.Name
        /// </summary>
        /// <param name="gid"></param>
        /// <param name="memberid"></param>
        /// <param name="companyid"></param>
        /// <param name="membertype"></param>
        /// <param name="createPersistentCookie"></param>
        public void SignIn(int uid, bool createPersistentCookie)
        {
            string ipAdd = HttpContext.Current.Request.UserHostAddress;

            FM_MemberDAL dal = new FM_MemberDAL();
            FormsAuthentication.SetAuthCookie(uid.ToString(), createPersistentCookie);
            //增加两段代码为跨域登录用,别删
            //  HttpCookie lcookie = HttpContext.Current.Response.Cookies[FormsAuthentication.FormsCookieName];
            //  lcookie.Domain = ".51camel.com";
            dal.MarkLoginInfo(uid, ipAdd);
        }

        public void SignOut()
        {

            //增加两段代码为跨域登录用
            //  HttpCookie lsCookie = HttpContext.Current.Response.Cookies[FormsAuthentication.FormsCookieName];
            //  lsCookie.Domain = ".51camel.com";
            FormsAuthentication.SignOut();
        }
    }
}